package dongbai.soft.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import dongbai.soft.utils.getUUID;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

/**
 * @author SingDeer
 * @email
 * @date 2023-06-29 15:51:52
 */
@Data
@TableName("good_order")
@NoArgsConstructor
@AllArgsConstructor
public class GoodOrderEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 货单唯一标识符
     */
    @TableId
    private String gid;
    /**
     * 商品名
     */
    private String pname;
    /**
     * 商品单价
     */
    private BigDecimal price;
    /**
     * 商品数量
     */
    private Integer pnum;
    /**
     * 货单类型（0购货单/1退货单/2亏损单）
     */
    private Integer type;
    /**
     * 支付状态（0未支付/1支付完成）
     */
    private Boolean ispaid = false;
    /**
     * 生成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime = new Date();
    /**
     * 处理时间
     */
    private Date dealTime;

    /**
     * 供应商唯一标识符
     */
    private String sid;

    public GoodOrderEntity(Map<String, Object> maps) {
        this.gid = getUUID.get6UUID();
        this.pname = (String) maps.get("name");
        this.price = new BigDecimal(String.valueOf(maps.get("wholesale_price")));
        this.pnum = Math.abs((Integer) maps.get("num"));
        this.type = (Integer) maps.get("status");
        this.sid = (String) maps.get("SID");
    }

}
